﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Agile.Genie.Descriptors;
using Agile.Genie.Generators;
using NUnit.Framework;

namespace GeneratorTests
{
    /// <summary>
    /// 
    /// </summary>
    [TestFixture]
    public class BuildFileGeneratorTests
    {
        #region CheckCodeGenerated Tests()

        /// <summary>
        /// Checks...
        /// </summary>
        [Test]
        public void CheckCodeGeneratedTests()
        {
            FileInfo file = GetCurrentProjectFile();
            BuildFileGenerator generator = BuildFileGenerator.Build(file);
            Assert.AreNotEqual(0, generator.Generate(), "a useless test");
        }

        private FileInfo GetCurrentProjectFile()
        {
            DirectoryInfo current = new DirectoryInfo(Environment.CurrentDirectory);
//            current.Parent.Parent
            DirectoryInfo projectDirectory = new DirectoryInfo(Path.Combine(current.Parent.Parent.Parent.FullName, "Generators"));

            return new FileInfo(Path.Combine(projectDirectory.FullName, "Generators.csproj"));
        }

        #endregion

        #region FindTestProject Tests()

        /// <summary>
        /// Checks...
        /// </summary>
        [Test]
        public void FindTestProjectTests()
        {
            FileInfo file = GetCurrentProjectFile();
            VisualStudioProjectFile projectFile = VisualStudioProjectFileFactory.Build(file);
            Assert.IsTrue(projectFile.HasTestProject);
        }

        #endregion
    }
}
